Repository navigation
feat: opt-in -1 from RowsAffected when no count is reported - #591
shiminlin-db wants to merge 4 commits into
Conversation
Result.RowsAffected() returns 0 both when a statement modified no rows and when the server reported no modified-row count (DDL such as CREATE VIEW), so callers cannot tell the two apart. Add WithReportUnknownRowsAffected / reportUnknownRowsAffected=true, off by default. When enabled, an unreported count is returned as -1: - Thrift: AffectedRows() returns -1 when NumModifiedRows is unset or there is no status response. - Kernel: normalizeAffectedRows keeps the C ABI's unknown sentinel as -1 instead of folding it to 0, so both backends stay in parity. A reported count, including 0, is unchanged. With the option off the behavior is the same as before. Refs #588 Signed-off-by: Shimin Lin <135086178+shiminlin-db@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 1 low concern. The option is wired through DSN parsing, DeepCopy, the Thrift backend and the kernel config, and each has unit tests. Whether the Thrift side works against a live server hasn't been checked yet. The question of making -1 the default is for the maintainers to decide.
Adds a credential-gated e2e test that runs CREATE/DROP TEMPORARY VIEW through ExecContext and checks RowsAffected is 0 by default and -1 with WithReportUnknownRowsAffected. The unit tests mock the status response, so this is what shows the server leaves NumModifiedRows unset for view DDL. Skips without warehouse credentials. Signed-off-by: Shimin Lin <135086178+shiminlin-db@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium
Looks good, with 1 medium concern. The option is wired correctly through the DSN, DeepCopy, the Thrift AffectedRows and the kernel normalizeAffectedRows, and has solid unit coverage. Follow-up: the kernel path has no live E2E coverage for the new option.
The nightly Thrift job selects tests with a -run allowlist, so TestE2EReportUnknownRowsAffected never ran there. Add it so the live server's NumModifiedRows behavior for view DDL is checked. Signed-off-by: Shimin Lin <135086178+shiminlin-db@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good, with 1 low concern. The option is wired consistently through the DSN, DeepCopy, the Thrift AffectedRows and the kernel's normalizeAffectedRows, and the default behavior is unchanged. Only the kernel half lacks end-to-end coverage.
Other findings
- ⚪ Nit — The new E2E test only exercises Thrift and the kernel-e2e nightly filter is unchanged, so no live test checks that the kernel really reports the -1 sentinel for view DDL. Unit tests do cover the config forwarding and normalizeAffectedRows, so this is a small coverage gap. Add a kernel-tagged variant and register it in the kernel-e2e
-runfilter. (Found by Claude Opus 5.5 · confirmed by the judge)
Moves the view DDL checks into a shared helper and adds TestKernelE2EReportUnknownRowsAffected, so a live test also confirms the kernel reports its unknown-count sentinel for view DDL. The kernel-e2e nightly filter selects the TestKernelE2E prefix, so it runs there without a workflow change. Signed-off-by: Shimin Lin <135086178+shiminlin-db@users.noreply.github.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Reply to the review bot's "Other findings" on 4cd8b43:
|
Fixes #588
Problem
Result.RowsAffected()returns0both when a statement modified no rows and when the server reported no modified-row count at all (DDL such asCREATE VIEW/DROP VIEW, or aSELECTrun throughExecContext). Callers cannot tell the two apart.AffectedRows()returns the generatedGetNumModifiedRows(), which yields0whenTGetOperationStatusResp.numModifiedRowsis unset (internal/backend/thrift/operation.go).-1when the count is not applicable, andnormalizeAffectedRowsfolds it to0for Thrift parity (internal/backend/kernel/affectedrows.go). The Statement Execution API has no modified-row field for non-DML statements, so every DDL /SELECTtakes this path.Change
Add
WithReportUnknownRowsAffected(bool)and the DSN parameterreportUnknownRowsAffected=true, default off.0.-1on both backends. A reported count, including0, is returned unchanged.Client-side only; nothing is sent to the server.
Compatibility
Returning
-1unconditionally would change what existing callers see for DDL viaExecContext(0today), and some treat0as "nothing modified". The option keeps today's behavior by default; callers who want the distinction opt in.Question for maintainers: the next release is the v2.0.0 prototype and already carries behavior changes. Do you want
-1to be the default (and drop the option), as was done for VARIANT type names in #576? The Python connector already reportscursor.rowcount = -1for an unreported count. Happy to make that change if preferred.Tests
internal/backend/thrift/operation_test.go: unset / nil status returns-1under the option; explicit0and positive counts are unchanged; the default path still returns0.internal/backend/kernel/affectedrows_test.go: the sentinel is kept as-1under the option; default folding is unchanged.connection_test.go:ExecContextend to end through the Thrift backend for both settings.connector_test.go,internal/config/config_test.go,kernel_config_test.go: option, DSN parsing (including a malformed value),DeepCopy, forwarding to the kernel config.go test ./...andgo vet ./...pass locally withCGO_ENABLED=0. The kernel-tagged call site ininternal/backend/kernel/operation.gois covered by theTest (kernel backend)CI job; it was not run locally.Not verified: whether the Thrift server leaves
numModifiedRowsunset (rather than0) for DDL against a live warehouse. The Thrift half of the change acts only when the field is unset.Docs
README, CONNECTION_PARAMETERS.md, doc.go, CHANGELOG (Unreleased).
This pull request and its description were written by Isaac.